package com.mimikko.example;

import android.app.Activity;
import android.graphics.Color;
import android.os.Build;
import android.view.View;
import android.view.WindowInsets;

public class ActivityUtils {

    public static void transparentSystemUI(Activity _this){
        _this.getWindow().setStatusBarColor(Color.TRANSPARENT);
        _this.getWindow().setNavigationBarColor(Color.TRANSPARENT);
    }

    public static void startImmersive(Activity _this) {
        int flags = View.SYSTEM_UI_FLAG_LAYOUT_STABLE
                | View.SYSTEM_UI_FLAG_FULLSCREEN
                | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION;
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            _this.getWindow().getDecorView().setSystemUiVisibility(
                    flags | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
                            | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY | View.SYSTEM_UI_FLAG_IMMERSIVE
            );
        } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
            _this.getWindow().getDecorView().setSystemUiVisibility(flags);
        }
        if(Build.VERSION.SDK_INT >= 30){

            _this.getWindow().setDecorFitsSystemWindows(true);
            _this.getWindow().getInsetsController().hide(WindowInsets.Type.statusBars() |WindowInsets.Type.systemBars() | WindowInsets.Type.systemGestures() );
        }
    }
}
